//
//  MQKey.m
//  YKRabbitMQSDK
//
//  Created by edward on 2020/6/17.
//  Copyright © 2020 edward. All rights reserved.
//

#import "MQKey.h"

@interface MQKey()
@property(nonatomic,strong) NSMutableArray *keys;
@end

@implementation MQKey

- (instancetype)initWithKeys:(NSArray *)arr
{
    self = [super init];
    if (self) {
        self.keys = [arr mutableCopy];
    }
    return self;
}

+ (instancetype)createMqKey:(NSArray *)keys
{
    return [[MQKey alloc]initWithKeys:keys];;
}

- (NSString *)getMqKeyStr
{
    //只有在GetKey的时候才添加*
    NSMutableArray *result = [NSMutableArray arrayWithArray:self.keys];
    return [result componentsJoinedByString:@"."];
}

- (NSArray *)getMqKeyArr
{
    return [self.keys copy];
}

- (MQKey * _Nonnull (^)(MQKey * _Nonnull roudingkeys))joinKey
{
    return ^MQKey *(MQKey *roudingkeys){
        return [self joinKey:roudingkeys];
    };
}

- (instancetype)joinKey:(MQKey *)newKey
{
    
    [self.keys addObjectsFromArray:newKey.keys];
    
    return self;
}

- (NSMutableArray *)keys
{
    if(!_keys)
    {
        NSMutableArray *marr = [[NSMutableArray alloc]init];
        _keys = marr;
    }
    return _keys;
}

@end
